package com.bishe.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bishe.dao.FestivalDao;
import com.bishe.domain.Festival;
import com.bishe.sevice.IFestivalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FestivalServicelmpl extends ServiceImpl<FestivalDao, Festival> implements IFestivalService {

    @Autowired
    private FestivalDao festivalDao;

    @Override
    public boolean modify(Festival festival) {
        return festivalDao.updateById(festival)>0;
    }

    @Override
    public boolean delete(Integer id) {
        return festivalDao.deleteById(id)>0;
    }

    @Override
    public List<Festival> GetBy(String uid) {
        QueryWrapper<Festival> qw = new QueryWrapper<>();
        qw.like("uid",uid);
        return festivalDao.selectList(qw);
    }

    @Override
    public IPage<Festival> getPage(int currentPage, int pageSize) {
        IPage page = new Page(currentPage,pageSize);
        festivalDao.selectPage(page,null);
        return page;
    }
}
